package com.kichina.parking.controller.base;

/**
 * @author Surging
 * @version 1.0
 * @ClassName IMessageHandler
 * @date 2022-06-16 14:01
 * @desc  控制层数据返回
 */
public class DataUpstreamResponse<T> extends BaseUpstreamResponse {
    private T data;

    public DataUpstreamResponse() {

    }

    public DataUpstreamResponse(String order_id, String message, int result_code, T data) {
        super(order_id, message, result_code);
        this.data = data;
    }

    public DataUpstreamResponse(String message, int result_code, T data) {
        super(message, result_code);
        this.data = data;
    }

    public static <T> DataUpstreamResponse<T> buildSuccess(T data) {
        return new DataUpstreamResponse<>("上传成功", 0, data);
    }

    public static <T> DataUpstreamResponse<T> buildFailed(String code, String message, T data) {
        return new DataUpstreamResponse<>("上传失败", 1, data);
    }

    public T getData() {
        return data;
    }
}
